<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 * @version		$Id: server.phtml 125 2011-04-12 03:34:30Z ninhgio@gmail.com $
 */

$this->headTitle($this->TRANSLATOR->translator('config_server_page_title') . ' - ' . $this->TRANSLATOR->translator('common_admin_title', 'core'));
?>
<div class="content">
	<div class="box header mb0">
		<div class="head"><div></div></div>
		<h2 class="g_a_breadcump">
			<a class="fl" href="<?php echo $this->url('core_dashboard_index'); ?>"><?php echo $this->TRANSLATOR->translator('dashboard_breadcump', 'core'); ?></a>
			<small class="icon arrow_right" style="display: block;"></small>
			<a class="fl" href="<?php echo $this->url('mail_mail_list'); ?>"><?php echo $this->TRANSLATOR->translator('mail_breadcump'); ?></a>
			<small class="icon arrow_right" style="display: block;"></small>
			<a class="fl" href="javascript: void(0);"><?php echo $this->TRANSLATOR->translator('config_server_breadcump'); ?></a>
			<div class="clear"></div>
		</h2>
	</div>
</div>
<div class="content">
	<div class="desc">
		<div class="body">
			<!--  -->
			<form action="<?php echo $this->url('mail_config_server'); ?>" method="post" id="mailConfigServer">
				<h4 class="g_a_h4 fl"><?php echo $this->TRANSLATOR->translator('config_server_guide'); ?></h4>
				<div class="fr">
					<?php if ($this->ACL->isAllowed('server', 'config', 'mail')) : ?>
					<a class="fl g_a_tip form_submit g_a_submit_button mr5" href="javascript: void(0);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('config_button_save_title')); ?>"></a>
					<?php endif; ?>
					<a class="fl g_a_tip g_a_cancel_button mr5" href="javascript: history.go(-1);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('common_back_button', 'core')); ?>"></a>
					<?php if ($this->ACL->isAllowed('list', 'mail', 'mail')) : ?>
					<a class="fl g_a_tip" href="<?php echo $this->url('mail_mail_list'); ?>" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('mail_actions_list_title')); ?>">
						<img src="<?php echo $this->APP_RESOURCE_SERVER; ?>/templates/<?php echo $this->APP_TEMPLATE; ?>/skins/<?php echo $this->APP_SKIN; ?>/images/actions_list_icon.png" style="padding: 0 5px 0 0;" />
					</a>
					<?php endif; ?>
				</div>
				<div class="g_a_line"></div>
				<p>
					<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_mail_protocol'); ?></label>
					<select name="config[protocol][protocol]" id="protocol" style="width: 200px">
						<option value="mail"<?php if (isset($this->configData) && $this->configData['protocol']['protocol'] == 'mail') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('config_use_php_mail'); ?></option>
						<option value="smtp"<?php if (isset($this->configData) && $this->configData['protocol']['protocol'] == 'smtp') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('config_use_smtp'); ?></option>
					</select>
					<?php if (isset($this->errorMessages) && isset($this->errorMessages['protocol'])) : ?>
					<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['protocol']); ?></span>
					<?php endif; ?>
					<br>
				</p>
				<p class="small">&nbsp;</p>
				<div id="smtpContainer" style="display: <?php if (isset($this->configData) && $this->configData['protocol']['protocol'] == 'smtp') : ?>block<?php else : ?>none<?php endif; ?>">
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_smtp_host'); ?></label>
						<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('config_smtp_host_description')); ?>" type="text" class="text w_20 g_a_tip_right" name="config[smtp][host]" id="host" value="<?php if (isset($this->configData['smtp']['host'])) : ?><?php echo $this->configData['smtp']['host']; ?><?php endif; ?>" />
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['host'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['host']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_smtp_port'); ?></label>
						<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('config_smtp_port_description')); ?>" type="text" class="text w_20 g_a_tip_right" name="config[smtp][port]" id="port" value="<?php if (isset($this->configData['smtp']['port'])) : ?><?php echo $this->configData['smtp']['port']; ?><?php endif; ?>" />
						<?php if (isset($this->errorMessages) && isset($this->errorMessages['port'])) : ?>
						<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['port']); ?></span>
						<?php endif; ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<p>
						<input type="checkbox" name="config[authentication]" id="authentication" value="true"<?php if (isset($this->configData['smtp']['username']) && $this->configData['smtp']['username'] != null) : ?> checked="checked"<?php endif; ?> /> <?php echo $this->TRANSLATOR->translator('config_smtp_authentication'); ?>
						<br>
					</p>
					<p class="small">&nbsp;</p>
					<div id="authenticationContainer" style="display: <?php if (!isset($this->configData['smtp']['username']) || $this->configData['smtp']['username'] == null) : ?>none<?php else : ?>block<?php endif; ?>">
						<p>
							<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_smtp_username'); ?></label>
							<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('config_smtp_username_description')); ?>" type="text" class="text w_20 g_a_tip_right" name="config[smtp][username]" id="username" value="<?php if (isset($this->configData['smtp']['username'])) : ?><?php echo $this->configData['smtp']['username']; ?><?php endif; ?>" />
							<?php if (isset($this->errorMessages) && isset($this->errorMessages['username'])) : ?>
							<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['username']); ?></span>
							<?php endif; ?>
							<br>
						</p>
						<p class="small">&nbsp;</p>
						<p>
							<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_smtp_password'); ?></label>
							<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('config_smtp_password_description')); ?>" type="password" class="text w_20 g_a_tip_right" name="config[smtp][password]" id="password" value="<?php if (isset($this->configData['smtp']['password'])) : ?><?php echo $this->configData['smtp']['password']; ?><?php endif; ?>" />
							<?php if (isset($this->errorMessages) && isset($this->errorMessages['password'])) : ?>
							<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['password']); ?></span>
							<?php endif; ?>
							<br>
						</p>
						<p class="small">&nbsp;</p>
						<p>
							<label for="simple_input"><?php echo $this->TRANSLATOR->translator('config_smtp_security'); ?></label>
							<select name="config[smtp][security]" id="security" style="width: 200px">
								<option value=""><?php echo $this->TRANSLATOR->translator('config_smtp_not_security'); ?></option>
								<option value="tls"<?php if (isset($this->configData) && $this->configData['smtp']['security'] == 'tls') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('config_smtp_tls'); ?></option>
								<option value="ssl"<?php if (isset($this->configData) && $this->configData['smtp']['security'] == 'ssl') : ?> selected="selected"<?php endif; ?>><?php echo $this->TRANSLATOR->translator('config_smtp_ssl'); ?></option>
							</select>
							<?php if (isset($this->errorMessages) && isset($this->errorMessages['security'])) : ?>
							<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['security']); ?></span>
							<?php endif; ?>
							<br>
						</p>
					</div>
				</div>
				<p class="small">&nbsp;</p>
				
				<p class="last buttons_demo">
					<?php if ($this->ACL->isAllowed('server', 'config', 'mail')) : ?>
					<a class="button form_submit green" href="<?php echo $this->url('mail_config_server'); ?>"><small class="icon check"></small><span><?php echo $this->TRANSLATOR->translator('common_submit_button', 'core'); ?></span></a>
					<?php endif; ?>
					<a class="button red" href="javascript: history.go(-1);"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_back_button', 'core'); ?></span></a>
					<?php if (isset($this->tokenElement)) : ?><?php echo $this->tokenElement; ?><?php endif; ?>
				</p>
			</form>
			<!--  -->
			<div class="clear"></div>
		</div>
	</div>
	<div class="body_footer">
		<div class="bottom_left"><div class="bottom_right"></div></div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	<?php if (($string = $this->MESSENGER->printMessages()) != null) : ?>
	Gio.Message.success('<?php echo $string; ?>');
	<?php endif; ?>
	
	$('#protocol').change(function() {
		if ($(this).val() == 'smtp') {
			$('#smtpContainer').show();
		} else {
			$('#smtpContainer').hide();
		}
	});

	$('#authentication').click(function() {
		if ($(this).is(':checked')) {
			$('#authenticationContainer').show();
		} else {
			$('#authenticationContainer').hide();
		}
	});
});
</script>